﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YummyHotDog;
using HotDog.HotDogIngredients;

namespace HotDog.HotDogPipeline
{
    public class ChoppedOnionOrderHandler : HotDogOrderHandler
    {
        public ChoppedOnionOrderHandler()
        {
            _hotDogIngredient = Ingredients.ChoppedOnion;
        }
        public override void ProcessRequest(IHotDogOrder hotDogOrder, Ingredients ingredients)
        {
            if (ClientWantsThis(ingredients))
            {
                hotDogOrder = new HotDogWithChoppedOnion(hotDogOrder);
            }

            if (_nextHotDogOrderStage != null)
                _nextHotDogOrderStage.ProcessRequest(hotDogOrder, ingredients);
            else Console.Write(hotDogOrder.ShowIngredients());
        }

        private bool ClientWantsThis(Ingredients ingredients)
        {
            var clientWish = (ingredients & _hotDogIngredient) == _hotDogIngredient;

            if (clientWish)
            {
                return true;
            }

            return false;
        }
    }
}
